{$header}
<tagLib name="html" />
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
<!--  功能组区域  -->
<div class="btn-toolbar">
	<div class="btn-group">
		<button class="btn btn-primary" onclick="doshipping()"> <i class="icon-inbox icon-white"></i>
			打包
		</button>
		<button class="btn btn-primary" onclick="foreverdel()"> <i class="icon-trash icon-white"></i>
			删除
		</button>
		<?php $ods = C('orderdetailstatus'); ?>
		<a href="__URL__/index" class="btn"><i class="icon-th-list"> </i>全部发货任务</a>
    <foreach name="ods" item="vo">
      <if condition="($key lt 5) and ($key gt -1) ">
       	<a href="__URL__/index/dstatus/{$key}" class="btn"><i class="icon-th-list"> </i>{$vo}</a>
   		</if>
    </foreach>
		
	</div>
	<form class="search-form" method='get' action="__URL__">
		每页显示<input type="text" class="span1" name="listRows" value="{$_REQUEST.listRows}">
		<select name="time_type" class="span1"> 
			<option value="1" <eq name="_REQUEST.time_type" value="1">selected</eq> >交货期</option> 
			<option value="2" <eq name="_REQUEST.time_type" value="2">selected</eq> >创建时间</option> 
		</select>
		从<input type="text" class="span2"  name="start_time" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<notempty name='_REQUEST.start_time'>{$_REQUEST.start_time}</notempty>">
		到<input type="text" class="span2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="end_time" id="end_time" value="<notempty name='_REQUEST.end_time'>{$_REQUEST.end_time}</notempty>" >
		
		{:configList( C('orderdetailstatus'),$_REQUEST['dstatus'],'dstatus' )}
    <input type="text" class="search-query span3" name="customer" <notempty name='_REQUEST.customer'>
        <php>echo 'value="'.urldecode($_REQUEST['customer']).'"'</php>
        <else/>
        placeholder="客户"
      </notempty> >
		<input type="text" class="search-query span4" name="keywords" <notempty name='_REQUEST.keywords'>
		<php>echo 'value="'.urldecode($_REQUEST['keywords']).'"'</php>
		<else/>
		placeholder="销售订单号，PO号，产品中文，英文，CAS号"
	</notempty>
	>
	<input type="submit" class="btn btn-primary" value="搜索">
	</form>
	
</div>
<!-- 功能组区域结束 -->
<php>
    function detail($id){
    echo ('<a href="__APP__/Order_detail/index/order_id/'.$id.'">销售明细</a>');
    }
    function toOd($time){
    echo toDate($time,'Y-m-d');
}

	function gstock($did){
    	$dorder = M('Order_detail');
    	$dorder->getById($did);
    	return getStock($dorder->product_id,$dorder->specification);
    }
</php>
<!-- 列表显示区域  -->
<div class="list" >
<div id="result" class="result none"></div>
<html:list id="checkList" pk="id" style="table table-bordered table-striped" name="action" checkbox="true"  datasource="list" show="id:编号|4%,mano:销售订单分号,id|getMsgTip:备注,po:PO号,customer_info:客户,total:总金额,real_pay:实际付款,pname:产品,cas:CAS,specification|getModelName=Specification:规格,number:数量,delivery_date|toOd:要求交货期,priority|getConfigVal='priority':优先级,currency|getConfigVal=Currency:货币,id|gstock:库存,remark:订单要求,user_id|getModelName=User:经办人,status|getConfigVal=orderDetailStatus:状态,id|getActionButton:操作" />
</div>
<!--  分页显示区域 -->
<div class="page">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<include file="Public:footer"/>
<script type="text/javascript">
	function toshipping(){
		location.href="__APP__/Shipping/toshipping";
	}
	function doshipping(id){
		var keyValue;
		if (id)
		{
			keyValue = id;
		}else {
			keyValue = getSelectCheckboxValues();
		}
		if (!keyValue)
		{
			alert('请选择销售单！');
			return false;
		}
			location.href="__URL__/doshipping/id/"+keyValue;
	}
</script>
<php>
function getActionButton($id){
	$sod = M('Order_detail');
	$sod ->getById($id);
	$status = $sod->status;
	switch($status){
		case 4: 	//到货通知
			echo "<a href='__URL__/doshipping/id/".$id."'>打包</a>";
			break;
		default:
			echo "<a href='__URL__/odetail/id/".$id."'>详情</a>";
			//echo "---";
}
}
</php>

<load href="__PUBLIC__/Js/My97DatePicker/WdatePicker.js" />
